package com.zf.yichat.api.controller.agreement;

import com.zf.yichat.api.controller.BaseController;
import com.zf.yichat.mapper.SysAgreementMapper;
import com.zf.yichat.model.SysAgreement;
import com.zf.yichat.utils.response.FsResponse;
import com.zf.yichat.utils.response.FsResponseGen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户协议&私密协议
 */
@RestController
@RequestMapping("agreement")
public class AgreementController extends BaseController {

    @Autowired
    private SysAgreementMapper agreementMapper;

    /**
     * 用户协议
     * @return
     */
    @PostMapping("/consumer")
    public FsResponse consumer() {
        // 获取用户协议内容地址
        SysAgreement agreement = agreementMapper.queryAgreementByName("consumer");
        if (null == agreement) {
            return FsResponseGen.failMsg("用户协议暂无配置！");
        }
        return FsResponseGen.successData(agreement.getContent());
    }

    /**
     * 私密协议
     * @return
     */
    @PostMapping("/privacy")
    public FsResponse privacy() {
        // 获取用户协议内容地址
        SysAgreement agreement = agreementMapper.queryAgreementByName("privacy");

        if (null == agreement) {
            return FsResponseGen.failMsg("隐私协议暂无配置！");
        }
        return FsResponseGen.successData(agreement.getContent());
    }

}
